package lexicalUnit;

import chalmersbot.Absyn.VerbBasic;
import chalmersbot.Absyn.VerbGoing;
import chalmersbot.Absyn.VerbGointTo;
import chalmersbot.Absyn.VerbIsVerb;
import chalmersbot.Absyn.VerbTo;
import chalmersbot.Absyn.Verb.Visitor;

public class CheckVerb implements Visitor<String, Environ> {

	@Override
	public String visit(VerbGoing p, Environ env) {
		return p.goingtoken_;
	}

	@Override
	public String visit(VerbTo p, Environ env) {
		return p.totoken_;
	}

	@Override
	public String visit(VerbBasic p, Environ arg) {
		return p.verbword_.accept(new CheckVerbWord(), arg);
	}

	@Override
	public String visit(VerbIsVerb p, Environ arg) {
		if (arg.resetFlag()==Environ.ISVERB_TENSE)
			throw new LexicalException("Wrong verb tense");
		return p.isvrb_.accept(new CheckIsVrb(), arg) + " " + p.vrb_.accept(new CheckVrb(), arg);
	}

	@Override
	public String visit(VerbGointTo p, Environ arg) {
		return p.goingwrd_.accept(new CheckGoingToWrd(), arg) + " " + p.towrd_.accept(new CheckToWrd(), arg) + " " + p.verbword_.accept(new CheckVerbWord(), arg);
	}


}
